#!/bin/bash
set -e

echo $PATH

mkdir -p /data/mongo/shard4/shard4-5801{1,3,5,7}
mkdir -p /data/mongo/shard4/logs

mongod -f shard4/shard4-58011.conf
mongod -f shard4/shard4-58013.conf
mongod -f shard4/shard4-58015.conf
mongod -f shard4/shard4-58017.conf


mongo --port 58011 << EOF
use admin 
var cfg ={"_id":"shard4", 
"protocolVersion": 1,
"members":[ 
    {"_id":1,"host":"172.17.0.4:58011"}, 
    {"_id":2,"host":"172.17.0.4:58013"}, 
    {"_id":3,"host":"172.17.0.4:58015"},
    {"_id":4,"host":"172.17.0.4:58017","arbiterOnly":true}] 
};
rs.initiate(cfg)
rs.status()
EOF
